package controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import action.DogCartAddAction;
import action.DogCartListAction;
import action.DogCartQtyDownAction;
import action.DogCartQtyUpAction;
import action.DogCartRemoveAction;
import action.DogListAction;
import action.DogMainAction;
import action.DogViewAction;

@WebServlet("*.dog")
public class DogFrontController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public DogFrontController() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}//doget

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String reqUri = request.getRequestURI();
		String contPath = request.getContextPath();
		String cmd = reqUri.substring(contPath.length());
		
		if(cmd.equals("/doglist.dog")){
			DogListAction list = new DogListAction();
			list.execute(request, response);
		}else if(cmd.equals("/dogview.dog")){
			DogViewAction view = new DogViewAction();
			view.execute(request, response);
		}else if(cmd.equals("/dogcartadd.dog")){
			DogCartAddAction cartadd = new DogCartAddAction();
			cartadd.execute(request, response);
		}else if(cmd.equals("/dogcartlist.dog")){
			DogCartListAction cartlist = new DogCartListAction();
			cartlist.execute(request, response);
		}else if(cmd.equals("/cartremove.dog")){
			DogCartRemoveAction cartremove = new DogCartRemoveAction();
			cartremove.execute(request, response);
		}else if(cmd.equals("/cartqtyup.dog")){
			DogCartQtyUpAction cartqtyUp = new DogCartQtyUpAction();
			cartqtyUp.execute(request, response);
		}else if(cmd.equals("/cartqtydown.dog")){
			DogCartQtyDownAction cartqtyDown = new DogCartQtyDownAction();
			cartqtyDown.execute(request, response);
		}else if(cmd.equals("/dogmain.dog")){
			DogMainAction dogmain = new DogMainAction();
			dogmain.execute(request, response);
		}
	}//dopost
}//class
